import request from '@/utils/request'
export default {
  namespaced: true,
  state: {
    id: '',
    username: '',
    mobile: '',
    sex: '',
    birthday: '',
    address: '',
    notes: '',
    password: '',
    icon: ''
  },
  mutations: {
    updateUserinfo (state, payload) {
      state.id = payload.id
      state.username = payload.username
      state.mobile = payload.mobile
      state.sex = payload.sex
      state.birthday = payload.birthday
      state.address = payload.address
      state.notes = payload.notes
      state.password = payload.password
      state.icon = payload.icon
    }
  },
  actions: {
    async  updateUser (context, data) {
      await request({
        url: '/user/update',
        method: 'POST',
        data
      })
      context.commit('updateUserinfo', data)
    }
  }
}
